function Trig_FactoryPage_Actions takes nothing returns nothing
	local integer abilityId = GetSpellAbilityId()
	local boolean haveSavedInteger = HaveSavedInteger(udg_AbilityToFactoryHashTable , abilityId , StringHash("FACTORY"))
	local integer factoryType = 0
	//--
	if haveSavedInteger then
		set factoryType = LoadInteger(udg_AbilityToFactoryHashTable , abilityId , StringHash("FACTORY"))
		call ReplaceUnitSimple(GetTriggerUnit() , factoryType)
		call UnitRemoveAbility(GetLastReplacedUnitBJ() , 'ARal')
	endif
endfunction

function InitTrig_FactoryPage takes nothing returns nothing
	set gg_trg_FactoryPage = CreateTrigger()
	call TriggerRegisterPlayerForceUnitEvent(gg_trg_FactoryPage , EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddAction(gg_trg_FactoryPage , function Trig_FactoryPage_Actions)
endfunction